package com.neu.wms.service.impl;


import com.neu.wms.dto.UserDto;
import com.neu.wms.vo.MenuVo;
import com.neu.wms.vo.UserVo;
import com.neu.wms.util.entity.SysUser;
import com.neu.wms.mapper.SysUserMapper;
import com.neu.wms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：fengSir
 * @date ：Created By 2023-06-20 10:30
 * @description ：TODO
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public String[] selectRoleByUsername(String userName) {
        return  sysUserMapper.selectRoleByUsername(userName);
    }

    @Override
    public String[] selectPermissionByName(String userName) {
        return sysUserMapper.selectPermissionByName(userName);
    }

    @Override
    public List<MenuVo> selectMenuByName(String userName, Integer parentId) {
        List<MenuVo> menuVos = sysUserMapper.selectMenuByName(userName, parentId);
        if (menuVos != null) {//递归调用退出的条件
            for (MenuVo menuVo : menuVos) {
                List<MenuVo> menuVos1 = selectMenuByName(userName, menuVo.getId());
                menuVo.setChildren(menuVos1);
            }
        }
        return menuVos;
    }

    @Override
    public List<UserVo> selectAll(UserDto userDto) {
        return sysUserMapper.selectAll(userDto);
    }

    @Override
    public SysUser selectByUsername(String userName) {
        return sysUserMapper.selectByUsername(userName);
    }

    @Override
    public SysUser selectByNameAndPwd(UserDto user) {
        return sysUserMapper.selectByNameAndPwd(user);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return sysUserMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SysUser record) {
        return 0;
    }

    @Override
    public int insertSelective(SysUser record) {
        return sysUserMapper.insertSelective(record);
    }

    @Override
    public SysUser selectByPrimaryKey(Long id) {
        return sysUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SysUser record) {
        return sysUserMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SysUser record) {
        return 0;
    }
}
